
import Tx from "../../utils/qqmap-wx-jssdk"

var qqmapsdk = new Tx({
  key: 'ESXBZ-STBWG-TETQZ-I32DT-4X4AT-NGB3D' 
});  


Page({

  data: {
    city:"",
    list:"",
    address:""
  },

  
  onLoad: function (options) {

  },

  
  getLocation(){
    var that = this;
    wx.getLocation({
      success(res){
        console.log(res);
        qqmapsdk.reverseGeocoder({
          location: `${res.latitude},${res.longitude}`,
          success(val){
            console.log(val);
            // console.log(val.result.location.address);
            
            that.setData({
              city:val.result.address_component.city,
              address:val.result.address
            })
          }
        });
        qqmapsdk.search({
          keyword:"影院",
          location:`${res.latitude},${res.longitude}`,
          success(result){
            console.log(result);
            that.setData({
              list:result.data
            })
            
          }
        })
      }
    })
  },

  onShow: function () {
   this.getLocation();
  },

})